package api

import (
	"alertmanagerWebhook/common"
	"alertmanagerWebhook/config"
	"alertmanagerWebhook/global"
	"net/http"

	"github.com/gin-gonic/gin"
)

func SendToDingding(c *gin.Context, notification config.Notification) {

	if err := common.SendToDingding(notification); err != nil {
		global.Logger.Errorln("Failed to send dingding notification:", err)
		c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}

	// 如果发送成功，返回成功响应
	c.JSON(http.StatusOK, gin.H{"status": "message sent successfully"})
}
